<template>
	<Layout class="p-5 bg-white">
		<Form :label-width="150">
			<Row>

					<Col span="8">
                        <FormItem class="w-100" label="车名">
                            <input v-model="car.name"/>
                        </FormItem>
                        <FormItem class="w-100" label="车龄">
                            <input v-model="car.carCondition"/>
                        </FormItem>
                        <FormItem class="w-100" label="表显里程">
                            <input v-model="car.mileage"/>
                        </FormItem>
                        <FormItem class="w-100" label="排量">
                            <input v-model="car.displacement"/>
                        </FormItem>
                        <FormItem class="w-100" label="车牌归属地">
                            <input v-model="car.ownerShip"/>
                        </FormItem>
                        <FormItem class="w-100" label="颜色">
                            <input v-model="car.color"/>
                        </FormItem>
						<FormItem class="w-100" label="价格">
						    <input v-model="car.rentalPrice"/>
						</FormItem>
                       	<FormItem class="w-100" label="车主姓名">
                       	    <input v-model="car.personName"/>
                       	</FormItem>
					</Col>
				
				
					<Col  span="8">
                        <FormItem class="w-100" label="车型">
                        	<input v-model="car.type"/>
                        </FormItem>
                        <FormItem class="w-100" label="排放标准">
                            <input v-model="car.standard"/>
                        </FormItem>
                        <FormItem class="w-100" label="座数">
                            <input v-model="car.seats"/>
                        </FormItem>
                        <FormItem class="w-100" label="燃油类型">
                            <input v-model="car.energy"/>
                        </FormItem>
						<FormItem class="w-100" label="驱动类型">
						    <input v-model="car.drive"/>
						</FormItem>
						<FormItem class="w-100" label="出场日期">
						    <el-date-picker
							v-model="car.productionDate" 
							type="datetime"
							value-format="yyyy-MM-dd HH:mm:ss"
							placeholder="请选择时间">	
							</el-date-picker>
						</FormItem>
						</FormItem>
						<FormItem class="w-100" label="国别">
						    <input v-model="car.country"/>
						</FormItem>
						<FormItem class="w-100" label="车主电话">
						    <input v-model="car.phone"/>
						</FormItem>
						<FormItem class="text-right">
							<Button @click="submit" type="primary">提交</Button>
							<Button @click="cancel" class="ml-2">取消</Button>
						</FormItem>
					</Col>		
			</Row>        
		</Form>
	</Layout>
</template>

<script>
	
	export default {
		data: function() {
			return {
				carId : 1,
				car : {}
				
			};
		},
		methods: {
			cancel: function() {
			
				this.$tabs.close();
			},
			submit: function() {
							let self = this;
							if (this.$data.car.name.length == 0) {
								this.message.error("车辆必须输入");
								return;
							}
							if (this.$data.car.mileage.length == 0) {
			
								this.message.error("里程必须输入");
								return;
							}
							if (this.$data.car.ct.length == 0) {
			
								this.message.error("创建时间");
								return;
							}
			
							this.http.put({
								url: "/car-rental-info/edit",
								param: self.car,
							}).then(() => {
								self.message.info("修改成功");
								self.$tabs.close();
							});
						},
			init: function() {
				
				
				let self = this;
			console.log(self.$data.carId)
				self.http.get({
					url: "/car-rental-info/one",
					param: {
						carId: self.$data.carId
					}
				}).then(data => {
					
					self.$data.car = data;
					console.log(self.$data.car)
				});
			    
			    
			
			}
		},
		created: function () {
			this.$data.carId = this.$route.params.carId;
			this.init();
		},
	}
</script>

<style>
</style>
